<template>
	<view class="content">
		<NavBar :title="title" :autoBack="false" id="nav">
			<template #left>
				<view class="navbar-left center" @click="goBack">
					<u-icon name="arrow-left" color="#007aff" size="34"></u-icon>
					<text class="c007aff">專案列表</text>
				</view>
			</template>
			
		</NavBar>
		<view class="widths list">
			<view class="flex dirCloumn item" v-for="(v,k) in list" :key="k" @click="toPage('Files',{id:curId,tit:title,name:v.name,path:v.filename})">
				<u-image src="../../static/img1.png" width="88rpx" height="88rpx" mode="aspectFill" border-radius="16rpx"></u-image> 
				<text class="f24">{{v.name}}</text>
			</view>
		</view>
		 
		<Tabar></Tabar>
	</view>
</template>

<script>
	import { mapState, mapMutations } from "vuex";
	import { getCaseName } from "@/api/apis.js"
	import NavBar from "@/component/NavBar"
	import Tabar from "@/component/HomeTab"
	import ZPaging from "@/node_modules/z-paging/components/z-paging/z-paging.vue"
	export default {
		components:{
			NavBar,
			ZPaging,
			Tabar
		},
		data() {
			return {
				isPc:null,
				title:"專案列表",
				list:[
					{
						name:"專案相關文件",
						filename:"files",
					},
					{
						name:"設計施工圖說",
						filename:"img",
					},
					{
						name:"設計原始檔案",
						filename:"zip",
					}
					
				],
				
			}
		},
		onShow(){
			
			const app = getApp();
			this.isPc=app.globalData.isPc
			uni.setStorageSync('tabIndex',0)
			// console.log("this",this.ismobile)
			this.$nextTick(()=>{
				const { id } = this.$Route.query
				this.curId=id
				if(uni.getStorageSync("islogin")){
					this.changeUserIdent(uni.getStorageSync('ident'))
					this.changeUserName(uni.getStorageSync('name'))
					if(!this.curId){
						this.$Toast("數據錯誤")
						setTimeout(()=>{
							this.toPage("Main")
						},1200)
					}else{
						this.init()
					}
				}else{
					this.$Toast("請先登錄")
					setTimeout(()=>{
						this.toPage("Home")
					},1200)
				}
			})
			
			
		},
		onLoad() {
		},
		
		computed: {
			...mapState(["userinfo"]),
		},
		methods: {
			...mapMutations(['chageUserPageType','chageUserPageId','changeUserIdent','changeUserName']),
			init(){
				let uid = uni.getStorageSync("uid")
				//獲取案例名稱
				getCaseName({id:this.curId,uid}).then((res)=>{
					this.title=res.title
				}).catch((err)=>{
					if(err.code === 102){
						this.$ClearLogin(err.msg)
					}else{
						this.$Toast(err.msg)
					}
				})
				
			},
			toPage(name,params={}){
				this.$navi({
				    route:{
				        name,
						params
				    },
				})
			},
			goBack(){
				// uni.navigateBack(-1)
				this.toPage('Main')
			},
		}
	}
</script>

<style lang="scss">
	page{
		background-color: #fdfdfd;
	}
	.content{
		min-height: 100vh;
		max-width: 750px;
		margin: 0 auto;
		padding-bottom: 40rpx;
	}
	.list{
		padding-top: 88rpx;
		display: flex;
		flex-wrap: wrap;
		.item{
			width: 33.3333%;
			padding-top: 30rpx;
		}
	}
</style>
